package com.ego.ware.po;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import lombok.Data;

/**
 * @program: ego
 * @description 商品库存
 * @author KamTang
 * @date 2022-11-13 13:30:29
 */
@Data
@TableName("wms_ware_sku")
public class WareSku implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@TableId
	private Long id;
	/**
	 * sku_id
	 */
	private Long skuId;
	/**
	 * 仓库id
	 */
	private Long wareId;
	/**
	 * 库存数
	 */
	private Integer stock;
	/**
	 * sku_name
	 */
	private String skuName;
	/**
	 * 锁定库存
	 */
	private Integer stockLocked;

	/**
	 * 商品库存初始化
	 * @param purchaseDetail @see
	 * @return 商品库存
	 * @see PurchaseDetail
	 */
	public static WareSku build(PurchaseDetail purchaseDetail) {
		WareSku wareSku = new WareSku();
		wareSku.setSkuId(purchaseDetail.getSkuId());
		wareSku.setStock(purchaseDetail.getSkuNum());
		wareSku.setWareId(purchaseDetail.getWareId());
		wareSku.setStockLocked(0);
		return wareSku;
	}
}
